Skip to content

Settings-table reader: comments, spreads, two rows on a line, unclosed rows - #571

Merged
scuttletoby merged 3 commits into
mainfrom
fix/417-settings-reader
Nov 20, 2026
Merged

scuttletoby merged 3 commits into
mainfrom
fix/417-settings-reader

Conversation

@scuttletoby

Copy link
Copy Markdown
Owner

Fixes #417

The reader of the fork settings pin table (.github/scripts/fork-changes-list.cjs, used by the FORK_CHANGES.md check) gets the five minors from the #404 lens.

  1. scopes !== 1 had no test. New case: { scope: SCOPE, key: "x", note: { scope: "server", key: "a" } } must throw (2 "scope:" but 1 read). With the check removed it reads as server.a, and the test fails.
  2. Comments counted as scope:. A row's text now has its comments stripped (string-aware, so a // in a URL inside a string is kept) before scope: is counted and scope: "..", key: ".." is read. A spread anywhere in a row (outside strings and comments) is refused.
  3. Two entries on one line. The issue suggests refusing more than one { per line. That would also refuse a valid one-line row with a nested object (default: { mode: "dark" }), so instead the row's text (strings and comments removed) must be exactly one top-level { ... }. { scope: "client", key: "b" }, { scope: "server", key: "c" }, now throws.
  4. Wrong error for an unrecognised },. While a row is open, any other line at the rows' two-space indent now throws, naming the line and the row it was meant to close, for example: `}, // end` at the rows' indent, but the row opened on line 12 has not closed. Before, it went on to the next row's close and reported 2 "scope:" but 2 read.
  5. Two-space indent of a row's },. New passing case: a row with a nested multi-line object whose }, sits at four spaces. If ROW_CLOSE is loosened to any indent, it fails.

Tests

node --test .github/scripts/fork-changes-list.test.cjs: 10 pass. Both new tests fail on the old code (checked). Mutation checks: removing each guard on its own (scopes !== 1, the comment strip, the spread refusal, the one-object check, the indent check, and loosening ROW_CLOSE) makes a new test fail. The real forkDefaults.ts table still reads cleanly.

State question: the reader is a pure function of the file's text, so a second run gives the same result and there is no half-finished state. Missing or empty input (no table, an empty table, no closing ];) was already tested and still throws.

General vs project

General: a fork CI check of the fork's own settings table. No project facts.

🤖 Generated with Claude Code

…d rows

The FORK_SETTING_DEFAULTS reader (fork-changes-list.cjs) now strips comments
before counting a row's "scope:", refuses a spread anywhere in a row and more
than one top-level object on a row's line, and names an unrecognised closing
line instead of reporting two rows read as one. Tests cover the scopes !== 1
check, each new refusal, and the two-space indent of a row's "},".

Fixes #417

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@scuttletoby

Copy link
Copy Markdown
Owner Author

Review (#417 fix): SAFE

Verdict: SAFE. All five items from #417 are handled. Anything the reader cannot parse throws; it is never read as "no row" or as a shorter list. One minor gap is left (a string can still stand in for a row's scope:). It was already there before this PR, it is contrived, and it is not a blocker.

What the reader decides: pinnedIds feeds only the FORK_CHANGES.md check in fork-changes-list.test.cjs (listed in .github/fork-ci-tests.txt). It does not choose which CI jobs run, so a wrong read cannot make CI skip tests. At worst the docs check would pass or fail wrongly.

Checked

  • node --test .github/scripts/fork-changes-list.test.cjs on the head (f0215db): 10 pass.

  • Both new #404 minors: settings-table reader test gap (scopes!==1), comments counted as scope #417 tests fail when run against main's reader (8 pass, 2 fail).

  • Extra probes on the new reader. Each throws, with the error named:

    • a nested spread in default: (throws "a spread in a row")
    • a row's close at 1 space followed by the next row (throws "{ at the rows' indent ... has not closed"; before, it threw 2 "scope:" but 2 read)
    • }, { at column 0 (throws "more than one { ... }")
    • an unclosed /* (throws 0 "scope:")
    • a trailing comment on a one-line row (throws "not a { ... } row")
    • a regex literal holding a quote (throws 2 "scope:")

    An apostrophe in a // comment reads correctly.

  • State question: pinnedIds is a pure function of the file's text, so a second run gives the same result and nothing is left half-done. A missing file throws in readRepoFile. A missing table, an empty table and a missing ]; throw too, and all of these are tested.

  • CI: all required checks pass (fork-ci-result pass). The branch is BEHIND main; the merge queue updates it.

Blocking: none.

Major: none.

Minor

  1. .github/scripts/fork-changes-list.cjs:119-120 (and the doc at :26-27): scope: is counted, and scope: "..", key: ".." is matched, in code. code still holds string contents. So a string can still supply a row's id when the row's real scope: is not written as scope: (shorthand scope,, or a quoted "scope": key):

    • { scope, key, note: "scope: 'server', key: 'fake'" } reads as server.fake.
    • { "scope": "client", "key": "real", note: "scope: 'server', key: 'fake'" } also reads as server.fake.

    Main's reader behaves the same way, so this is not a regression. But the stripRow doc says "neither a comment nor a string can stand in for the row's own scope:", and that is not yet true for strings. Fix: count \bscope: in bare, and also require exactly one \bscope:\s*(""|''),\s*key:\s*(""|'') match in bare. Then add one of the two rows above as a test case.

  2. Nit, .github/scripts/fork-changes-list.cjs:104-108: any spread in a row is refused, including a nested one (default: { ...BASE, on: true }), as #404 minors: settings-table reader test gap (scopes!==1), comments counted as scope #417 asked. That is fine because it fails closed. But for a nested spread the hint "write each row's scope and key in the row itself" points at the wrong thing; "no spreads anywhere in a row" would be clearer.

…417)

Review minor on #571: count scope: outside strings and require exactly one
scope/key pair outside strings, so a row whose own scope is shorthand or a
quoted key is refused instead of read from a string. Clearer message for a
nested spread.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@scuttletoby

Copy link
Copy Markdown
Owner Author

Fix for the review minors (ec65d79):

  • scope: is now counted outside strings, and exactly one scope: "..", key: ".." pair must be found outside strings. A row whose own scope is shorthand (scope,) or a quoted key is refused instead of being read from a string. The stripRow comment is now true.
  • New cases in the #404 minors: settings-table reader test gap (scopes!==1), comments counted as scope #417 test: both rows from the review and a row with a real pair plus a string pair. The first fails on the previous head.
  • A nested spread's message now says no spreads anywhere in a row.

All 10 tests pass.

@scuttletoby
scuttletoby merged commit f3096e0 into main Nov 20, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

#404 minors: settings-table reader test gap (scopes!==1), comments counted as scope

1 participant